package com.panopset.game.cojack;

/**
 * Float wrapper used to combine odds of sequential events.
 *
 * @author Karl Dinwiddie
 *
 */
public class Odds {

    /**
     * Chances of an event happening.
     */
    private final float c;

    /**
     * Pass .50f for a coin toss, .25f for a 1:4 chance.
     *
     * @param chance
     *            Chances of this event happening.
     */
    public Odds(float chance) {
        c = chance;
    }

    /**
     * @return Chance of this event happening.
     */
    public float getChance() {
        return c;
    }

    /**
     * Simple multiplication of sequential event odds to determine actual odds
     * of something happening in sequence.
     *
     * @param chance
     *            Odds object to combine odds for.
     * @return new Odds(chance * getChance()).
     */
    public Odds combine(Odds chance) {
        return combine(chance.getChance());
    }

    /**
     * Simple multiplication of sequential event odds to determine actual odds
     * of something happening in sequence.
     *
     * @param chance
     *            Sequential event odds to combine odds for.
     * @return new Odds(chance * getChance()).
     */
    public Odds combine(float chance) {
        return new Odds(chance * getChance());
    }

}
